/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author edilson
 */
@Entity
@Table(name = "Turma")
public class Turma implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    private String nome;
//    @JoinColumn(name = "disciplina", referencedColumnName = "id")
//    @ManyToOne
//    private Disciplina disciplina;
    
    @JoinColumn(name = "disciplinaProfessor", referencedColumnName = "id")
    @ManyToOne
    private DisciplinaProfessor disciplinaProfessor;
//    
//    @OneToMany(mappedBy = "turma")
//    private List<Plano> planos;
    @OneToMany(mappedBy = "turma", cascade= CascadeType.ALL)
    private List<Matriculado> matriculados;
    @OneToOne(mappedBy = "turma", cascade= CascadeType.ALL)
    private Plano plano;

    public Turma() {
    }

    public Turma(Integer id) {
        this.id = id;
    }

    public Turma(Integer id, DisciplinaProfessor disciplinaProfessor) {
        this.id = id;
        this.disciplinaProfessor = disciplinaProfessor;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

//    public Integer getCh() {
//        return ch;
//    }
//
//    public void setCh(Integer ch) {
//        this.ch = ch;
//    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

//    public Disciplina getDisciplina() {
//        return disciplina;
//    }
//
//    public void setDisciplina(Disciplina disciplina) {
//        this.disciplina = disciplina;
//    }

    public DisciplinaProfessor getDisciplinaProfessor() {
        return disciplinaProfessor;
    }

    public void setDisciplinaProfessor(DisciplinaProfessor disciplinaProfessor) {
        this.disciplinaProfessor = disciplinaProfessor;
    }
    
    public List<Matriculado> getMatriculados() {
        return matriculados;
    }

    public void setMatriculados(List<Matriculado> matriculados) {
        this.matriculados = matriculados;
    }
    
    
//
//    public List<Plano> getPlanos() {
//        return planos;
//    }
//
//    public void setPlanos(List<Plano> planos) {
//        this.planos = planos;
//    }

    public Plano getPlano() {
        return plano;
    }

    public void setPlano(Plano plano) {
        this.plano = plano;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Turma)) {
            return false;
        }
        Turma other = (Turma) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Turma[id=" + id + "]";
    }
}
